<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <?php include_once MvcReg::$_moduleName . '/views/layout/head.php'; ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
    <link rel="stylesheet" href="webroot/admin/bootstrap-datetimepicker.css?>"/>

    <style>
        .bootstrap-select.form-control:not([class*="col-"]){
            width: 150px;
        }
    </style>
</head>
<body>
<?php include_once MvcReg::$_moduleName . '/views/layout/woody-prompt.php'; ?>
<?php include_once MvcReg::$_moduleName . '/views/layout/header.php'; ?>
<div id="main">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-2">
                <?php include_once MvcReg::$_moduleName . '/views/layout/left_menu.php'; ?>
            </div>
            <div class="col-md-10">
                <div class="right-content">
                    <h3>
                        <ol class="breadcrumb">
                            <li><a href="?md=store&cl=order&at=orderlist"><i class="fa fa-dashboard"></i><?php echo $menu["breadcrumb_current"] ?></a></li>
                        </ol>
                    </h3>
                    <br>
                    <form name="mainform" action="" method="get">
                    <?php echo $hidden_data?>
                    <div class="table-responsive">
                        <div class="panel panel-default">
                            <div class="panel-body form-inline">
                                <div style="float:left">
                                    <div  style="overflow: hidden">
                                        <div class="form-group">
                                            <label>配货单号:</label>
                                            <input type="text" name="_ph_no"
                                                   value="<?php echo $_ph_no ?>"
                                                   class="form-control input-sm" placeholder=""/>
                                        </div>

                                        <div class="form-group">
                                            <label>订单号:</label>
                                            <input type="text" name="_order_no"
                                                   value="<?php echo $_order_no ?>"
                                                   class="form-control input-sm" placeholder=""/>
                                        </div>

                                        <div class="form-group">
                                            <label>订单状态:</label>
                                            <select class="form-control select" name="_order_status" >
                                                <option value="0">全部</option>
                                                <?php
                                                unset(Data::$_order_status[6]);
                                                foreach( Data::$_order_status as $K => $vl){
                                                    if($_order_status== $K){
                                                        $selected = 'selected="selected"';
                                                    }else{
                                                        $selected = '';
                                                    }
                                                    echo ' <option '.$selected.' value="'.($K+100).'">'.$vl.'</option>';
                                                }?>
                                            </select>
                                        </div>

                                        <div class="form-group">
                                            <label>订单来源:</label>
                                            <select class="form-control select" name="_source" >
                                                <option value="">请选择...</option>
                                                <?php foreach($sourceLists as $souK => $souName){
                                                    if($_source == $souK){
                                                        $selected = 'selected="selected"';
                                                    }else{
                                                        $selected = '';
                                                    }
                                                    echo ' <option '.$selected.' value="'.$souName.'-'.$souK.'">'.$souName.'</option>';
                                                }?>
                                            </select>
                                        </div>
                                    </div>
                                        <div class="form-group">
                                            <label>配送方式:</label>
                                            <?php echo Tools::selectOptions("_express_type", Data::$_express_type, '全部', true, $_express_type, 'class="form-control select"'); ?>
                                        </div>
                                        <div class="form-group">
                                            <label>下单时间:</label><input type="text" name="startdate" id="dstartDate" class="form-control" placeholder="" value="<?php echo $startdate ?>" autocomplete="off"/>
                                            -- <input type="text" name="enddate" id="dendDate" class="form-control" placeholder="" value="<?php echo $enddate ?>" autocomplete="off"/>
                                        </div>
                                        <button type="submit" class="btn btn-primary"><span
                                                    class="glyphicon glyphicon-search"></span>立即查询
                                        </button>
                                   </div>
                                  <div class="floatright">
                                    <div class="dataTables_filter">
                                        <a href="javascript:;" onclick="exp('<?php echo $_ph_no ?>','<?php echo $_order_no ?>','<?php echo $_order_status ?>','<?php echo $sourceN ?>','<?php echo $_shop_no ?>','<?php echo $_store_no ?>','<?php echo $_express_type ?>','<?php echo $_riders ?>','<?php echo $startdate ?>','<?php echo $enddate ?>')" class="btn btn-primary"><b>汇出</b></a>
                                    </div>
                                  </div>
                                </div>

                            </div>
                        </div>

                        <table class="table table-hover">
                            <thead>
                            <tr class="info">
                                <th>序</th>
                                <th>分司名称</th>
                                <th>配货单号</th>
                                <th>订单编号</th>
                                <th>配送门店</th>
                                <th>订单状态</th>
                                <th>配送方式</th>
                                <th>预计送达时间</th>
                                <th>配送费</th>
                                <th>订单来源</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            if($rsp_list){

                            $n = 0;
                            foreach ($rsp_list as $k => $row) {
                                $n++;
                                $item = $n + ($page - 1) * $number_page;
                                $id = $row["id"];
                                $express_type =Data::$_express_type[$row["express_type"]] ;
                                if ($row['express_type'] == "no") {
                                    $express_type= "<label class='red'>".$express_type."</label>";
                                }
                                if($row['status'] >= 0 ){
                                    foreach (Data::$_order_status as $ok=>$ov){
                                        if($row['status'] == $ok){
                                            $status = $ov;
                                        }
                                    }
                                }

                                ?>
                                <tr data-id="<?php echo $id?>">

                                    <td><?php echo $item ?></td>
                                    <td><?php echo $row["name"] ?></td>
                                    <td><?php echo $row["ph_no"] ?></td>
                                    <td><?php echo $row["order_no"] ?></td>
                                    <td><?php echo $row["shop_name"] ?></td>
                                    <td><?php echo $status ?></td>
                                    <td><?php if($row['status']  > 0 ){ echo $express_type;} ?></td>
                                    <td><?php echo $row["delivery_time"] ?></td>
                                    <td><?php echo $row["express_fee"] ?></td>
                                    <td><?php echo $row["source"] ?></td>
                                    <td>
                                        <input name="input" value="查看"
                                               onclick="edit('<?php echo $id; ?>', '<?php echo $page; ?>','<?php echo $this_url?>_check')"
                                               type="button" class="btn btn-success btn-sm"/>
                                    </td>
                                </tr>
                            <?php }
                            }
                            ?>
                            </tbody>
                        </table>
                        <div class="page">
                                <div class="pagination pull-left">共<?php echo $total_count ?>笔记录</div>
                                <?php if (!empty($rsp_page_list)) echo $rsp_page_list; ?>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<?php include_once MvcReg::$_moduleName . '/views/layout/footer.php'; ?>

<script src="webroot/admin/bootstrap-datetimepicker.min.js?v=<?php echo constant('JSCSS_VERSION')?>" type="text/javascript"></script>
<script src="webroot/admin/bootstrap-datetimepicker.zh-CN.js?v=<?php echo constant('JSCSS_VERSION')?>" type="text/javascript"></script>
<script>

    $('#dstartDate').datetimepicker({
        format: 'yyyy-mm-dd',
        autoclose:true,
        minView:3,
        language:  'zh-CN',
        weekStart: 1,
        todayBtn : true,
        todayHighlight :true,
        keyboardNavigation:true,
        showMeridian:false,
        initialDate:new Date(),
    }).on('changeDate',function(e){
        $("#dendDate").datetimepicker('setStartDate',$(this).val());
        $("#dendDate").datetimepicker('hide');
        var date1 = new Date($(this).val());
        var date2 = new Date($("#dendDate").val());
        if(date2){
            var date3=date1.getTime()-date2.getTime();
            var days=Math.abs(date3/(24*3600*1000));
            if(days > 30){
                alert("超过查询时间最大限制30天");
                $(this).val('');
                return false;
            }
        }

    });
    // 结束时间：
    $('#dendDate').datetimepicker({
        format: 'yyyy-mm-dd',
        autoclose:true,
        minView:2,
        language:  'zh-CN',
        weekStart: 1,
        todayBtn : true,
        todayHighlight :true,
        keyboardNavigation:true,
        showMeridian:false,
        initialDate:new Date(),
        // startDate:new Date(),
    }).on('changeDate',function(e){
        $("#dstartDate").datetimepicker('setEndDate',$(this).val());
        $("#dstartDate").datetimepicker('hide');

        var date1 = new Date($(this).val());
        var date2 = new Date($("#dstartDate").val());
        if(date2){
            var date3=date1.getTime()-date2.getTime();
            var days=Math.abs(date3/(24*3600*1000));
            if(days > 30){
                alert("超过查询时间最大限制30天");
                $(this).val('');
                return false;
            }
        }
    });

    $("#pickupTime").datetimepicker({
        minView: "month",
        format : "yyyy-mm-dd",
        autoclose:true,
        todayBtn: true
    });


    function exp(_ph_no,_order_no,_order_status,_source,_shop_no,_store_no,_express_type,_riders,startdate,enddate) {
        window.location.href = "?md=store&cl=order&at=export&_ph_no="+_ph_no+"&_order_no="+_order_no+"&_order_status="+_order_status+"&_source="+_source+"&_shop_no="+_shop_no+"&_store_no="+_store_no+"&_express_type="+_express_type+"&_riders="+_riders+"&startdate="+startdate+"&enddate="+enddate;
    }
</script>
</body>
</html>
